package com.example.demo.controller;

import com.example.demo.mapper.domain.Images;
import com.example.demo.mapper.domain.Word;
import com.example.demo.resp.CommonResp;
import com.example.demo.service.Imageservice;
import com.example.demo.service.Wordservice;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
public class Test {
    @Resource
    private Wordservice wordservice;
    @Resource
    private Imageservice imageservice;
    //返回列表
    @GetMapping("/wordlist")
    public CommonResp reword(){
        return wordservice.list();
    }
    //查找文章
    @GetMapping("/fword")
    public CommonResp fword(String id){
        return wordservice.find(id);
    }
    //返回图片
    @GetMapping("/fimage")
    public List<Images> fimage(String id)
    {
        return imageservice.findid(id);
    }
    //返回所有图片
    @GetMapping("/fallimage")
    public List<Images> all()
    {
        return imageservice.all();
    }
    //上传图和文字
    @PostMapping("/add-word")
    public CommonResp adddata(@RequestBody Word word)
    {
        return wordservice.add(word);
    }
    @GetMapping("/del")
    public CommonResp deleaat(String id){
        return wordservice.delet(id);
    }
}
